<template>
    <div class="listDiv mt10">
        <div class="searchDiv">
            <DateRange v-model:start="obj.req.start" v-model:end="obj.req.end" sph="起止时间" />
            <span class="btn search" @click="init">搜索</span>
            <span class="btn refresh" @click="obj.req.currentpage=1;init"></span>
            <div class="searchRight">
            </div>
        </div>
        <div ref="img1" style="width:100%; height: 100%;"></div> 
    </div>
</template>

<script setup>
    import { reactive, getCurrentInstance, ref, toRefs, onMounted, nextTick } from 'vue'
    import DateRange from '@/components/date_range.vue'
    let { proxy } = getCurrentInstance()

    let obj = reactive({
        ary: [],
        req: {
            currentpage: 1,
            pagesize: 10,
            count: 0,
            start:"",
            end:"",
        }
    });
    let init = () => {
        var option = {
            title: {
                text: '发电量统计',
                // subtext: 'Fake Data',
                left: 'center'
            },
            color: [
                "#5470c6",
                "#73c0de",
                "#3ba272",
                "#fc8452",
                "#9a60b4",
                "#ea7ccc"
            ],
            tooltip: {
                trigger: 'item'
            },
            legend: {
                orient: 'vertical',
                left: 'left'
            },
            series: [{
                name: 'Access From',
                type: 'pie',
                radius: '50%',
                data: [
                    { value: 1048, name: 'Search Engine' },
                    { value: 735, name: 'Direct' },
                    { value: 580, name: 'Email' },
                    { value: 484, name: 'Union Ads' },
                    { value: 300, name: 'Video Ads' }
                ],
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }]
        };
        var myChart = proxy.$echarts.init(proxy.$refs["img1"]);
        option && myChart.setOption(option);
    }
    onMounted(() => {
        nextTick(() => {
            init()
        })
    });
</script>